Frame Grabber Initialization

This chapter introduces how to call the SDK APIs to control frame grabbers, such as enumeration, turning on/off, configuring frame grabbers.

Basic flows include:
  1. Enumerate Frame Grabber(s)
  2. Create Frame Grabber Instance
  3. Turn on Frame Grabber
  4. (Optional) Configure Parameters
  5. Turn off Frame Grabber
  6. Destroy Frame Gravver Instance

Prerequisite

Before you continue, make sure SDK has been initialized. For more details, refer to SDK Initialization.

Step 1 Enumerate Frame Grabber(s)

Call MV_CC_EnumInterfaces() and enter the frame grabber type nTLayerType, to get the frame grabber list of the corresponding type (pInterfaceInfoList).
interfaceList = MV_INTERFACE_INFO_LIST()
transportLayerType = MV_GIGE_INTERFACE | MV_CAMERALINK_INTERFACE | MV_CXP_INTERFACE | MV_XOF_INTERFACE | MV_LC_INTERFACE
# Enumerate frame grabbers
ret = MvCamera.MV_CC_EnumInterfaces(transportLayerType, interfaceList)
if ret != 0:
print("enum interfaces fail! ret[0x%x]" % ret)
sys.exit()
Note
Details for frame grabber interfaces:
Frame Grabber Interface Type Value Description
MV_GIGE_INTERFACE 0x00000001 GigE Vision Frame Grabber.
MV_CAMERALINK_INTERFACE 0x00000004 Camera Link Frame Grabber.
MV_CXP_INTERFACE 0x00000008 CoaXPress Frame Grabber.
MV_XOF_INTERFACE 0x00000010 XoFLink Frame Grabber.
MV_VIR_INTERFACE 0x00000020 Virtual frame grabber.
MV_LC_INTERFACE 0x00000040 Board type light controller.

Step 2 Create Frame Grabber Instance

You can create frame grabber instance through frame grabber information or ID.
  • Option 1: Call MV_CC_CreateInterface() and pass the frame grabber information pInterfaceInfo to create the corresponding frame grabber instance.

    # Create an instance
    interface_instance = MvCamera()
    # Select the frame grabber, and create a handle
    curInterface = cast(interfaceList.pInterfaceInfos[int(nInterfaceIndex)], POINTER(MV_INTERFACE_INFO)).contents
    ret = interface_instance.MV_CC_CreateInterface(curInterface)
    if ret != 0:
    raise Exception("create interface handle fail! ret[0x%x]" % ret)
  • Option 2: Call MV_CC_CreateInterfaceByID() and pass the frame grabber ID pInterfaceID to create the corresponding frame grabber instance. ID can be the serial No.

    Note
    In this way, you just need to pass the serial No. of the frame grabber rather than enumerate frame grabber in advance.

    The following codes show how to create the frame grabber with the serial No. "DA1433238" via MV_CC_CreateInterfaceByID().

    # Create an instance
    interface_instance = MvCamera()
    chInterfaceID = 'DA1433238';
    ret = interface_instance. MV_CC_CreateInterfaceByID (chInterfaceID)
    if ret != 0:
    raise Exception("create interface handle fail! ret[0x%x]" % ret)

Step 3 Turn On Frame Grabber

"Turn on the frame grabber" refers to establishing the connection between the frame grabber instance and physical frame grabber, and making the frame grabber instance gaining access to the frame grabber.
You can call MV_CC_OpenInterface() to turn on the frame grabber. The return value MV_OK stands for success. Other return values indicate failure.
# Turn on the device
ret = interface_instance.MV_CC_OpenInterface()
if ret != 0:
raise Exception("open interface fail! ret[0x%x]" % ret)
else:
print("open interface success")


(Optional) Step 4 Configure Parameters

Corresponding SDK APIs can be called after turning on the frame grabber to achieve functions as follows:

Step 5 Turn off Frame Grabber

When the communication between frame grabber instance and physical frame grabber is no longer needed, call MV_CC_CloseInterface() to turn off the frame grabber.
The sample code is as follows:
# Turn off the frame grabber
interface_instance.MV_CC_CloseInterface()


Step 6 Destroy Frame Grabber Instance

Call MV_CC_DestroyInterface() to destroy frame grabber instance and release the resource occupied by the instance.
Attention
After destroying frame grabber instance, the previous instance is invalid, and cannot be used for other APIs.
The sample code is as follows:
# Destroy frame grabber handle
interface_instance.MV_CC_DestroyInterface()
Note
After realizing functions through SDK, you need to release SDK resources. For more details, refer to SDK Initialization.